<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul>
        <li>元素1</li>
        <li>元素2</li>
        <li>元素3</li>
    </ul>
</body>
<script>
    //const 用于常量(不改变的)
    //let 常量
    //用css选择器获取dom元素
    //document.querySelector()   选择第一个元素
    //document.querySelectorAll() 选择所有元素 返回伪数组
    const a = document.querySelector('li');
    console.log(a);
    const b = document.querySelectorAll('li:nth-child(2)');
    const c = document.querySelectorAll('li:first-child');
    const d = document.querySelectorAll('li:last-child');
    console.log(b);
    console.log(c);
    console.log(d);
    const all = document.querySelectorAll('li');
    console.log(all);
</script>

</html>